<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="logList" @selection-change="handleSelectionChange">
      <el-table-column align="center" label="修改类型" prop="type">
        <template slot-scope="{ row }">
          <span :style="{ color: row.type === 0 ? 'blue' : '' }">{{ row.type === 0 ? '机构' : '任务' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="任务ID" align="center" prop="tiskId" />
      <el-table-column label="操作人员" align="center" prop="operatorName" />
      <el-table-column align="center" label="操作类型" prop="operationType">
        <template slot-scope="{ row }">
          <span :style="{ color: row.operationType === 1 ? 'black' : 'red' }">{{ row.operationType === 1 ? '开' : '关'
            }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作时间" align="center" prop="createTime">
        <template slot-scope="{ row }">
          <span>{{ row.createTime.slice(0, 19).replace('T', ' ') }}</span>
        </template>
      </el-table-column>

    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />


  </div>
</template>

<script>
import { listLog } from "@/api/merchant/log";

export default {
  name: "Log",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 商户操作明细表格数据
      logList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        infoId: null,
        infoName: null,
        tiskId: null,
        operatorId: null,
        operatorName: null,
        operationType: null,
        type: null,
        describe: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  watch: {
    $route() {
      this.getList()
    }
  },
  methods: {
    /** 查询商户操作明细列表 */
    getList() {
      this.loading = true;
      this.queryParams.infoId = this.$route.query.infoId;
      listLog(this.queryParams).then(response => {
        this.logList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        infoId: null,
        infoName: null,
        tiskId: null,
        operatorId: null,
        operatorName: null,
        operationType: null,
        createTime: null,
        type: null,
        describe: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },


  }
};
</script>
